package com.etc.service;

import com.etc.entity.Hospital;
import com.etc.entity.Notice;
import com.etc.mapper.NoticeMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    public String noticeAdd(@Param("notice_title")String notice_title,@Param("notice_content")String notice_content){
        Notice notice = new Notice();
        notice.setNotice_title(notice_title);
        notice.setNotice_content(notice_content);
        notice.setNotice_date(new Date());
        noticeMapper.noticeAdd(notice);
        return "添加公告成功";
    }
    public String noticeDelete(int id){
        noticeMapper.noticeDelete(id);
        return "删除公告成功";
    }
    public Notice noticeQueryById(int id){
        Notice notice = noticeMapper.noticeQueryById(id);
        return notice;
    }
    public List<Notice> queryTen(){
        List<Notice> notices = noticeMapper.noticeQueryTen();
        return notices;
    }
    public List<Notice> queryAll(){
        List<Notice> notices = noticeMapper.noticeQueryAll();
        return notices;
    }
    public String modify(@Param("notice_title")String notice_title,@Param("notice_content")String notice_content,@Param("notice_id")int notice_id){
        Notice notice = new Notice();
        notice.setNotice_id(notice_id);
        notice.setNotice_title(notice_title);
        notice.setNotice_content(notice_content);
        noticeMapper.noticeModify(notice);
        return "修改公告成功";
    }
    public List<Notice> queryByTitle(String title){
        List<Notice> notices = noticeMapper.noticeQueryByTitle(title);
        return notices;
    }

}
